package com.devunion.bogdan.services;

import com.devunion.bogdan.model.project.Paper;
import com.devunion.bogdan.model.project.Project;
import com.devunion.bogdan.model.project.dao.PaperDao;
import com.devunion.bogdan.model.project.dao.ProjectDao;
import com.devunion.bogdan.spring.Context;

import java.util.List;

/**
 * @author Viktar Liaskovich (devunion@gmail.com)
 */
public class SearchService {
    private static SearchService instance;
    private PaperDao paperDao;
    private ProjectDao projectDao;

    private SearchService() {
        paperDao = (PaperDao) Context.getContext().getBean("paperDao");
        projectDao = (ProjectDao) Context.getContext().getBean("projectDao");
    }

    public static SearchService getInstance() {
        if (instance == null) {
            instance = new SearchService();
        }

        return instance;
    }

    public List<Paper> search(String name, String type) {
        return paperDao.search(name, type);
    }

    public List<Project> findSimilar(Project project) {
        return projectDao.loadAll();
    }
}
